package com.service;

import com.dao.ShopMapper;
import com.dao.UserMapper;
import com.pojo.Shop;
import com.pojo.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ShopService {

    @Resource
    private ShopMapper shopMapper;
    @Resource
    private UserMapper userMapper;

    public List<Shop> findAll() {
        return shopMapper.findAll();
    }

    public Shop findById(Integer id) {
        return shopMapper.findById(id);
    }

    public void insert(Shop shop, User user) {
        shopMapper.insert(shop);
        user.setBuyManerId(shopMapper.selectLastId());
        userMapper.update(user);
    }

    public void update(Shop shop) {
        shopMapper.update(shop);
    }

    public void deleteById(Integer id) {
        shopMapper.deleteById(id);
    }
}
